﻿<!--#include file="../inc/common.asp" -->
<!--#include file="waputil.asp" -->
<%
  response.contentType="text/vnd.wap.wml"
  'response.contentType="text/xml"
  response.charset=DEFAULT_CHARSET
  response.buffer = true  

  on error resume next

  dim blogItem
  set blogItem = new BlogItemClass
  blogItem.load(clng(request("content_id")))
  
%>
<?xml version="1.0" encoding="<%=DEFAULT_CHARSET%>"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapfourm.org/DTD/wml_1.1.xml">
<wml>
<%
    dim comments, comment, count, index, from, comment_id, i
    comments = blogItem.getComments()
    count = 0
    if isArray(comments) then
        count = ubound(comments)
    end if    

    index = request("ct_index")
    if index="" then
      index = 0
      from = -1
    elseif index="last" then
      index = count - 1 
      from = count
    else
      index = cint(index)
      from = request("from")
      if from = "" then
        from = -1
      else
        from = cint(from)
      end if  
    end if
    
    if index<0 then 
      index = 0
    elseif index>count -1 then
      index = count - 1
    end if
    
    comment_id = request("comment_id")
    if trim(comment_id)<> "" then
        comment_id = clng(comment_id)
        for i=0 to count-1
          if comments(i).commentId = comment_id then
            index = i
            exit for
          end if
        next
    end if
    
    set comment = comments(index)
%>
<card title="第<%=index + 1%>条评论" newcontext="false" ordered="true">

<p><b><%=blogItem.title%></b><br/><br/>
<%= comment.insertTime%><br/>
<b><%=HTML2WML(comment.userName)%></b>：

<%
  dim bodyUrl,bodyTxt,pageno
  pageno = request("pageno")
  bodyUrl = "comment.asp?blog_id=" & blogItem.blogId & "&amp;content_id=" & blogItem.itemId & "&amp;ct_index=" & index & "&amp;from=" & from & "&amp;pageno_list=" & request("pageno_list")& "&amp;pageno_comments=" & request("pageno_comments")
  if comment.isSecret then
    response.write "--悄悄话--"
  end if
  if not comment.isSecret  or userRightObj.canReadSecret or (userObj.userId<>"" and userObj.userId=comment.userId) then
    bodyTxt = HTML2WML(comment.detail)
    response.write wmlTxtPage(bodyTxt, pageno) & "<br/>" 
    response.write wmlTxtPageLink(bodyTxt, pageno, bodyUrl) & "<br/>" 
  end if
%>

</p>
<p>
<%
sub writePrevComment
  if index>0 then
    set comment = comments(index - 1)
	response.Write("<a href='comment.asp?blog_id=" & blogItem.blogId & "&amp;content_id=" & blogItem.itemId & "&amp;ct_index=" & (index-1) & "&amp;from=" & index & "&amp;pageno_list=" & request("pageno_list") & "&amp;pageno_comments=" & request("pageno_comments") & "'>查看上一评论</a>(共" & lenb(comment.detail) & "字节)<br/>")
  end if
end sub

sub writeNextComment
  if index < count-1 then
    set comment = comments(index + 1)
	response.Write("<a href='comment.asp?blog_id=" & blogItem.blogId & "&amp;content_id=" & blogItem.itemId & "&amp;ct_index=" & (index+1) & "&amp;from=" & index & "&amp;pageno_list=" & request("pageno_list") & "&amp;pageno_comments=" & request("pageno_comments") & "'>查看下一评论</a>(共" & lenb(comment.detail) & "字节)<br/>")
  end if
end sub

if from > index then
  writePrevComment
  writeNextComment
else  
  writeNextComment
  writePrevComment
end if  

response.Write("<a href='comments.asp?blog_id=" & blogItem.blogId & "&amp;content_id=" & blogItem.itemId & "&amp;pageno_list=" & request("pageno_list") & "&amp;pageno_comments=" & request("pageno_comments") & "'>[返回评论列表]</a><br/>")

%>
<a href="reply.asp?blog_id=<%=blogItem.blogId%>&amp;content_id=<%=blogItem.itemId%>&amp;comment_id=<%=comment.commentId%>&amp;pageno_list=<%=request("pageno_list")%>">[发表评论]</a><br/>
<a href="detail.asp?blog_id=<%=blogItem.blogId%>&amp;content_id=<%=blogItem.itemId%>&amp;pageno_list=<%=request("pageno_list")%>">[返回正文]</a><br/>
<a href="list.asp?blog_id=<%=blogItem.blogId%>&amp;pageno_list=<%=request("pageno_list")%>">[返回<%=HTML2WML(blogObj.blogTitle)%>首页]</a><br/>
<a href="list.asp">[返回最新文章列表]</a>
</p>
<%
  writeBlogOptions
%>
</card>
</wml>
<%
  set blogItem = nothing
  closeDB()
  'session.abandon
%>